package cn.hcbycloud.common.permission.config;


import cn.hcbycloud.auth.client.ExternalPermissionCheckClient;
import cn.hcbycloud.common.permission.service.PermissionCheckService;
import cn.hcbycloud.common.permission.service.impl.PermissionCheckServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author gaoh
 * @desc 通用配置组件包配置类
 * @date 2022年01月12日 下午 5:07
 */
@Configuration
@AllArgsConstructor
public class CommonConfig {
    /**
     * 认证中心暴露的feign接口
     */
    ExternalPermissionCheckClient externalPermissionCheckClient;
    /**
     * 默认实现JWTredis缓存配置
     * 默认实现bean,该bean在单体项目中可自定义实现
     */
    @Bean(name = "permissionCheckService")
    @ConditionalOnMissingBean(PermissionCheckService.class)
    public PermissionCheckService getPermissionCheckService() {
        return new PermissionCheckServiceImpl(externalPermissionCheckClient);
    }
}